package org.flexspeedup.utils
{
import flash.events.Event;
import flash.events.IEventDispatcher;

import org.swizframework.core.IDispatcherAware;

/**
 * A standard implementation of IDispatcherAware
 */
public class SwizDispatcherBase implements IEventDispatcher, IDispatcherAware
{
    //--------------------------------------------------------------------------
    //
    // Constructor
    //
    //--------------------------------------------------------------------------

    /**
     * Creates a new instance of this class.
     */
    public function SwizDispatcherBase()
    {
    }

    //--------------------------------------------------------------------------
    //
    //  IDispathcerAware implementation
    //
    //--------------------------------------------------------------------------
    
    //----------------------------------
    //  _dispatcher
    //----------------------------------
    /**
     *  @private
     */
    private var _dispatcher:IEventDispatcher;

    /**
     *  @private
     *  IDispatcherAware implementation
     */
    public function set dispatcher(dispatcher:IEventDispatcher):void
    {
        _dispatcher = dispatcher;
    }

    //--------------------------------------------------------------------------
    //
    //  IEventDispatcher implementation using swiz dispatcher
    //
    //--------------------------------------------------------------------------
    
    public function addEventListener(type:String, listener:Function, 
                                     useCapture:Boolean = false, 
                                     priority:int = 0, 
                                     useWeakReference:Boolean = false):void
    {
        _dispatcher.addEventListener(type, listener, useCapture, priority);
    }
    
    public function dispatchEvent(event:Event):Boolean
    {
        return _dispatcher.dispatchEvent(event);
    }
    
    public function hasEventListener(type:String):Boolean{
        return _dispatcher.hasEventListener(type);
    }
    
    public function removeEventListener(type:String, listener:Function, 
                                        useCapture:Boolean = false):void
    {
        _dispatcher.removeEventListener(type, listener, useCapture);
    }
    
    public function willTrigger(type:String):Boolean
    {
        return _dispatcher.willTrigger(type);
    }
}
}